package io.xccit.race.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.xccit.common.annotation.Log;
import io.xccit.common.core.controller.BaseController;
import io.xccit.common.core.domain.AjaxResult;
import io.xccit.common.enums.BusinessType;
import io.xccit.race.domain.RaceCompetitionAppeal;
import io.xccit.race.service.IRaceCompetitionAppealService;
import io.xccit.common.utils.poi.ExcelUtil;
import io.xccit.common.core.page.TableDataInfo;

/**
 * 竞赛申诉管理Controller
 * 
 * @author ywx
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/race/appeal")
public class RaceCompetitionAppealController extends BaseController {
    @Autowired
    private IRaceCompetitionAppealService raceCompetitionAppealService;

    /**
     * 查询竞赛申诉管理列表
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:list')")
    @GetMapping("/list")
    public TableDataInfo list(RaceCompetitionAppeal raceCompetitionAppeal) {
        startPage();
        List<RaceCompetitionAppeal> list = raceCompetitionAppealService.selectRaceCompetitionAppealList(raceCompetitionAppeal);
        return getDataTable(list);
    }

    /**
     * 导出竞赛申诉管理列表
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:export')")
    @Log(title = "竞赛申诉管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RaceCompetitionAppeal raceCompetitionAppeal) {
        List<RaceCompetitionAppeal> list = raceCompetitionAppealService.selectRaceCompetitionAppealList(raceCompetitionAppeal);
        ExcelUtil<RaceCompetitionAppeal> util = new ExcelUtil<RaceCompetitionAppeal>(RaceCompetitionAppeal.class);
        util.exportExcel(response, list, "竞赛申诉管理数据");
    }

    /**
     * 获取竞赛申诉管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(raceCompetitionAppealService.selectRaceCompetitionAppealById(id));
    }

    /**
     * 新增竞赛申诉管理
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:add')")
    @Log(title = "竞赛申诉管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RaceCompetitionAppeal raceCompetitionAppeal) {
        return toAjax(raceCompetitionAppealService.insertRaceCompetitionAppeal(raceCompetitionAppeal));
    }

    /**
     * 修改竞赛申诉管理
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:edit')")
    @Log(title = "竞赛申诉管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RaceCompetitionAppeal raceCompetitionAppeal) {
        return toAjax(raceCompetitionAppealService.updateRaceCompetitionAppeal(raceCompetitionAppeal));
    }

    /**
     * 删除竞赛申诉管理
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:remove')")
    @Log(title = "竞赛申诉管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(raceCompetitionAppealService.deleteRaceCompetitionAppealByIds(ids));
    }

    /**
     * 审核申诉
     */
    @PreAuthorize("@ss.hasPermi('race:competitionAppeal:audit')")
    @Log(title = "竞赛申诉管理", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody RaceCompetitionAppeal raceCompetitionAppeal) {
        return toAjax(raceCompetitionAppealService.auditRaceCompetitionAppeal(raceCompetitionAppeal));
    }
}
